//
//  DXWMineViewController.m
//  pandaTV
//
//  Created by 淡馨慰 on 16/8/19.
//  Copyright © 2016年 淡馨慰. All rights reserved.
//

#import "DXWMineViewController.h"
#import "UIBarButtonItem+DXWBarButtonItem.h"
#import "DXWSettingViewController.h"
#import "DXWMineArrowItem.h"
#import "DXWMineArrowLoginItem.h"
#import "DXWMineGroupItem.h"

@interface DXWMineViewController ()

/** cell的组 */
@property (nonatomic, strong) NSMutableArray *groupsArray;

@end

@implementation DXWMineViewController

- (NSMutableArray *)groupsArray
{
    if (_groupsArray == nil) {
        _groupsArray = [NSMutableArray array];
    }
    return _groupsArray;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor colorWithRed:230/255.0 green:230/255.0 blue:230/255.0 alpha:1];
    self.title = @"我的";
    
    //1. 设置NavigationBar属性
    [self setValueForNavigationBar];
    
    //添加组模型
    [self setGroup0];
    [self setGroup1];
    [self setGroup2];
    [self setGroup3];
    [self setGroup4];
    self.tableView.contentInset = UIEdgeInsetsMake(-dxw_margin_20, 0, 0, 0);
    self.tableView.sectionHeaderHeight = 0;
    self.tableView.sectionFooterHeight = dxw_margin_10;
//    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
}
//第4组模型
- (void)setGroup4
{
    //创建行模型
    DXWMineArrowItem *item0 = [DXWMineArrowItem rowItemWithImage:[UIImage imageNamed:@"mine_suggestIcon"] title:@"私信"];
    UIView *line = [[UIView alloc]initWithFrame:CGRectMake(0, 0, screenW, 1)];
    line.backgroundColor = [UIColor lightGrayColor];
    DXWMineArrowItem *item1 = [DXWMineArrowItem rowItemWithImage:[UIImage imageNamed:@"shake_icon"] title:@"摇一摇"];
        DXWMineArrowItem *item2 = [DXWMineArrowItem rowItemWithImage:[UIImage imageNamed:@"mine_activityIcon"] title:@"活动中心"];
        DXWMineArrowItem *item3 = [DXWMineArrowItem rowItemWithImage:[UIImage imageNamed:@"mine_remindIcon"] title:@"开播提醒"];
        DXWMineArrowItem *item4 = [DXWMineArrowItem rowItemWithImage:[UIImage imageNamed:@"mine_suggestIcon"] title:@"意见反馈"];
    NSArray *itemArray = @[item0,item1,item2,item3,item4];
    //创建组模型
    DXWMineGroupItem *groupItem = [DXWMineGroupItem groupItemWithRowItemArray:itemArray];
    [self.groupArray addObject:groupItem];
}
//第3组模型
- (void)setGroup3
{
    //创建行模型
    DXWMineArrowItem *item0 = [DXWMineArrowItem rowItemWithImage:[UIImage imageNamed:@"mine_histroyIcon"] title:@"观看历史"];
    NSArray *itemArray = @[item0];
    //创建组模型
    DXWMineGroupItem *groupItem = [DXWMineGroupItem groupItemWithRowItemArray:itemArray];
    [self.groupArray addObject:groupItem];
}
//第2组模型
- (void)setGroup2
{
    //创建行模型
    DXWMineArrowItem *item0 = [DXWMineArrowItem rowItemWithImage:[UIImage imageNamed:@"mine_attentionIcon"] title:@"我的订阅"];
    NSArray *itemArray = @[item0];
    //创建组模型
    DXWMineGroupItem *groupItem = [DXWMineGroupItem groupItemWithRowItemArray:itemArray];
    [self.groupArray addObject:groupItem];
}
//第1组模型
- (void)setGroup1
{
    //创建行模型
    DXWMineArrowItem *item0 = [DXWMineArrowItem rowItemWithImage:[UIImage imageNamed:@"mine_zhubo"] title:@"我要当主播"];
    NSArray *itemArray = @[item0];
    //创建组模型
    DXWMineGroupItem *groupItem = [DXWMineGroupItem groupItemWithRowItemArray:itemArray];
    [self.groupArray addObject:groupItem];
}
//第0组模型
- (void)setGroup0
{
    //创建行模型
    DXWMineArrowLoginItem *item = [DXWMineArrowLoginItem rowItemWithImage:[UIImage imageNamed:@"photo_default3_icon"] title:@"点击登录"];
    NSArray *itemArray = @[item];
    //创建组模型
    DXWMineGroupItem *groupItem = [DXWMineGroupItem groupItemWithRowItemArray:itemArray];
    [self.groupArray addObject:groupItem];
}
#pragma mark -设置NavigationBar属性
- (void)setValueForNavigationBar
{
    self.navigationItem.rightBarButtonItem = [UIBarButtonItem barButtonItemWithImage:[UIImage imageNamed:@"mine_settingIcon2"] higtLightedImage:[UIImage imageNamed:@"mine_settingIcon2_press"] target:self action:@selector(settingBtnClick)];
}
#pragma mark -监听设置按钮点击
- (void)settingBtnClick
{
    NSLog(@"%s",__func__);
    //跳转设置界面
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"DXWSettingViewController" bundle:nil];
    UIViewController *settingVC = [storyboard instantiateInitialViewController];
    settingVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:settingVC animated:YES];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        return 75;
    }
    else
        return 40;
}


@end
